#include<iostream>
#include<vector>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long ll;

ll check(ll h){
    ll s = sqrt(2 * h);
    while (s * (s + 1) / 2 > h) s--;
    while ((s + 1) * (s + 2) / 2 <= h) s++;
    return s;
}

void solve() {
    ll h,d,f=0;
    cin>>h>>d;
    ll res=0;
    while(d>0) {
        ll s=check(h);
        cout<<s<<' ';
        if(s>=d){
            res+=d;
            break;
        }
        res+=s;
        d-=s;
        ll t=s*(s+1)/2;
        h-=t;
        if (h<t && d>0) {
            ll temp=t-h;
            res+=temp;
            h=t;    
        }
    }
    cout<<res<<'\n';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}